package com.aios.action.user.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.aios.action.AbstractManagementAction;
import com.aios.entity.SystemUser;
import com.aios.entity.SystemUserPassword;
import com.aios.exception.ItemNotFoundException;
import com.aios.exception.NullReferenceAccessException;
import com.aios.service.SystemUserService;

public abstract class AbstractSystemUserAction extends AbstractManagementAction {

	private static final long serialVersionUID = 1L;
	protected SystemUser systemUser;
	protected SystemUserPassword systemUserPassword;

	@Qualifier("systemUserService")
	@Autowired protected SystemUserService systemUserService;
	
	public SystemUser findById() {
		
		if(id != null) {
			try{
				return systemUserService.findById(id);
			}catch(Exception e) {
				throw new ItemNotFoundException("Id : " + id);
			}
		} else {
			//logger
			throw new NullReferenceAccessException("Id cannot be null");
		}
	}
	
	public SystemUser getSystemUser() {
		return systemUser;
	}
	
	public void setSystemUser(SystemUser systemUser) {
		this.systemUser = systemUser;
	}
}
